package xyz.ddlnt.commonutil.util;

import de.mkammerer.argon2.Argon2;
import de.mkammerer.argon2.Argon2Factory;

/**
 * 密钥派生加密工具类
 *
 * @author ZZULI_SE 210910
 * @data 2025/4/26 14:02
 */
public class Argon2Util {

    private static final Argon2 argon2 = Argon2Factory
            .create(Argon2Factory.Argon2Types.ARGON2id, 16, 64);
    /**
     * @description: 密码加密
     *
     * @param: password
     * @return: java.lang.String
     */
    public static String hashPassword(String password) {
        return argon2.hash(10, 65536, 1, password.toCharArray());
    }

    /**
     * @description: 密码校验
     *
     * @param: hashPassword
     * @param: password
     * @return: java.lang.Boolean
     */
    public static Boolean verifyPassword(String hashPassword, String password) {
        return argon2.verify(hashPassword, password.toCharArray());
    }
}
